import React from "react";
import './index.css'
const CounterContext = React.createContext()

function Counter() {
  const {count, setCount} = React.useContext(CounterContext)
  return (<button onClick={() => setCount(count + 1)}>+</button>)
}

function App() {
  const [count, setCount] = React.useState(0)
  const data = {setCount, count}
  return (
    <CounterContext.Provider value={data}>
      <div className='red'>
        {count}
        <hr/>
        <Counter />
      </div>
    </CounterContext.Provider>
  )
}

export default App
